package com.yiyi.credit.manage.abutment.common.bean;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.yiyi.credit.manage.abutment.common.enums.ResponseCode;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;

@JsonInclude(JsonInclude.Include.NON_NULL)
@ApiModel(value = "事件处理结果")
public class Response<T> implements Serializable {

    private static final long serialVersionUID = 355207958304927788L;


    @ApiModelProperty(value = "处理结果编码，10000:success")
    private String code = "10000";
    @ApiModelProperty(value = "处理结果信息")
    private String message = "success";
    private T result;
    private Long timestamp = System.currentTimeMillis();

    public Response() {

    }

    public Response(ResponseCode code) {
        this.code = code.getCode();
        this.message = code.getMessage();
    }

    public Response(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public Response(String message) {
        this.message = message;
    }

    public Response(T result) {
        this.result = result;
    }

    public Response(T result, ResponseCode code) {
        this.result = result;
        this.code = code.getCode();
        this.message = code.getMessage();
    }

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public Response setMessage(String message) {
        this.message = message;
        return this;
    }

    public T getResult() {
        return result;
    }

    public void setResult(T result) {
        this.result = result;
    }

    public Long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(Long timestamp) {
        this.timestamp = timestamp;
    }

}
